package com.sky.loveshop.service.impl;

import com.sky.loveshop.entity.OrderDetail;
import com.sky.loveshop.mapper.OrderDetailMapper;
import com.sky.loveshop.service.OrderDetailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @author xcy
 * @version V1.0
 * @description
 * @date 2024/11/3 22:50
 */
@Slf4j
@Service
public class OrderDetailServiceImpl implements OrderDetailService {

    @Autowired
    private OrderDetailMapper orderDetailMapper;

    @Override
    public Integer batchInOrderDetail(List<OrderDetail> orderDetailList) {
        return orderDetailMapper.insertList(orderDetailList);
    }

    @Override
    public List<OrderDetail> getDetailListByOrderId(Integer orderId) {
        Example example = new Example(OrderDetail.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("orderId", orderId);
        List<OrderDetail> OrderDetails = orderDetailMapper.selectByExample(example);
        return OrderDetails;
    }
}
